﻿using ASPNETVN.PORTAL.Components.UI;
using System;
using System.Web.UI.WebControls;

namespace CUSTOMS.Modules.QLHS.Controls
{
    public partial class TheoDoiChungTu : ModulePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void PageDropDownList_SelectedIndexChanged(Object sender, EventArgs e)
        {
            DropDownList ddl = (DropDownList)sender;
            gvChungTu.PageIndex = ddl.SelectedIndex;
            gvChungTu.DataBind();
        }

        protected void gvChungTu_DataBound(object sender, EventArgs e)
        {
            if (gvChungTu.Rows.Count > 0)
            {
                // Retrieve the pager row.
                GridViewRow bottomPagerRow = gvChungTu.BottomPagerRow;
                GridViewRow topPagerRow = gvChungTu.TopPagerRow;

                // Retrieve the DropDownList and Label controls from the row.
                DropDownList topPageList = (DropDownList)topPagerRow.Cells[0].FindControl("PageDropDownList");
                DropDownList bottomPageList = (DropDownList)bottomPagerRow.Cells[0].FindControl("PageDropDownList");
                Label topPageLabel = (Label)topPagerRow.Cells[0].FindControl("PageLabel");
                Label bottomPageLabel = (Label)bottomPagerRow.Cells[0].FindControl("PageLabel");

                if (topPageList != null && bottomPageList != null)
                {
                    for (int i = 0; i < gvChungTu.PageCount; i++)
                    {
                        int pageNumber = i + 1;
                        ListItem item = new ListItem(pageNumber.ToString());
                        if (i == gvChungTu.PageIndex)
                        {
                            item.Selected = true;
                        }

                        topPageList.Items.Add(item);
                        bottomPageList.Items.Add(item);
                    }
                }

                if (topPageLabel != null && bottomPageLabel != null)
                {
                    topPageLabel.Text = bottomPageLabel.Text = " / " + gvChungTu.PageCount.ToString();
                }
            }
        }

        protected void btnThongKe_Click(object sender, EventArgs e)
        {

        }
    }
}